import index_a, index_b, listed_co, bond_detail, listed_financing, acquisition
from comm_tools.date_tool import get_last_day_of_previous_month
from datetime import date, timedelta

def history_index_b():
    end_date = get_last_day_of_previous_month()
    for i in range(24):
        index_b.upload(end_date)
        begin_date = end_date.replace(day=1)
        end_date = begin_date - timedelta(days=1)

def history_listed_co():
    end_date = get_last_day_of_previous_month()
    for i in range(24):
        listed_co.upload(end_date)
        begin_date = end_date.replace(day=1)
        end_date = begin_date - timedelta(days=1)

if __name__ == '__main__':
    # 万得数据 - 每月第一天
    index_a.upload() # 2 3 4 5 6 7
    # index_b.upload()  # 2 3 4 5 6 7
    # listed_co.upload()  # 2 3 4 5 6 7
    # 公司融资数据 - 每月初公司一处提供
    # bond_detail.upload() # 债权融资 2 3 4 5 6 7
    # listed_financing.upload() # 上市公司融资 2 3 4 5 6 7
    #acquisition.upload() # 并购重组 2 3 4 5 6 7

    # 补充上传历史数据（已上传，无需操作）
    # history_index_b()
    # listed_co.upload(date(2024, 11, 30))
    # history_listed_co()
